<?php
error_reporting(E_ALL);
$xml = new DOMDocument('1.0');
$xml->validateOnParse = true;
$xml->formatOutput = true;

$xml->load('xml_template.xml');
$xpath = new DOMXPath($xml);


    if(isset($_POST['imeSektora'])) {
        $imeSektora = $_POST['imeSektora'];
    } else {
        $imeSektora = '';
    };

    $file1 = 'word/organogram.xml';
    //$file2 = 'word/organogram-'.$imeSektora.'.xml';
    $file2 = 'word/organogram-sektor.xml';
    $file3 = 'word/text-sektor.xml';
    $sve = 'word/sve.xml';   
    $fileout  = 'word/sve.xml'; 
// w:body
// w:p

// load the xml into the object
$xml3 = simplexml_load_file('word/organogram.xml');
$namespaces = $xml3->getNameSpaces(true);
$xml3->registerXPathNamespace('w', $namespaces['w']);
$nodes = $xml3->xpath('/w:document/w:body/w:p');


$files = array( 'word/organogram.xml', 'word/organogram-sektor.xml');

$xml = new SimpleXMLElement(<<<XML
<?xml version="1.0" encoding="utf-8"?>
<contents>
</contents>
XML
);

foreach( $files as $filename) {
    $xml_int = simplexml_load_file( $filename );
    $conts = $xml_int->children('w',true);
    $content = $xml->addChild( 'content'); // add content
    $content->addChild( 'title',$conts->title); // add first title
    // add the rest of the content insides
    // ...
}
var_export($xml->asXML());

?>